<template>
	<view class="main">
		<u-navbar :is-back="false" :background="background" :border-bottom="false" height="64">
			<view class="whole">
				<view class="content">
					<view class="head" @click="router()">
						<image src="../../../static/images/serch.png" mode=""></image>
						<input type="text"  v-model="title" @blur="serch()" />
					</view>
					<view class="content_r" solt="right" @click="back">
						取消
					</view>
				</view>
			</view>
		</u-navbar>
		<view class="all">

			<view class="classes" v-for="(item,index) in classlist" :key="index"
				@click="item.type==1?go('../../classes/details/details',item.id,item):go('../../classes/privilege/privilege',item.id,item)">
				<view class="one_of">
					<view class="class_l">
						<image :src="item.cover" mode=""></image>
					</view>
					<view class="class_r">
						<view class="topic">{{item.title}}</view>
						<text class="name">讲师：{{item.lecturer}}</text>
					</view>
				</view>
				<view class="one_bottom">
					<text class="bot_l">{{item.count}}节课</text>
					<text class="bot_r">立即学习</text>
				</view>
			</view>
			<view class="none" v-if="classlist.length<1">
				<u-empty text="没有匹配到搜索结果" mode="search"></u-empty>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#FFFFFF',
				},
				title: '',
				classlist: [],
				level: ''

			}
		},
		onShow() {},
		onLoad(options) {
			this.serch()
			this.getlevel()
		},

		methods: {
			//权限
			getlevel() {
				global.$http.request({
					url: '/api/User/info',
					data: {
						token: uni.getStorageSync('token')
					}
				}).then(res => {
					if (res.data.code == 200) {
						// console.log(res);
						this.level = res.data.data
					}
				})
			},
			go(path, id, info) {
				// console.log(JSON.stringify(info));
				// console.log(JSON.parse(JSON.stringify(info)));
				uni.navigateTo({
					url: path + '?id=' + id + '&info=' + encodeURIComponent(JSON.stringify(info))
				})
			},
			router() {
				uni.navigateTo({
					url: '../../indexs/index/index',
					animationType: 'none',
					animationDuration: 200
				})
			},
			back() {
				uni.navigateBack({
					delta: 1,
					"animationType": "zoom-fade-in",
					"animationDuration": 300
				})
			},
			serch() {
				global.$http.request({
					url: '/api/home/search',
					data: {
						token: uni.getStorageSync('token'),
						title: this.title
					}
				}).then(res => {
					if (res.data.code = 200) {
						console.log(res.data.data);
						this.classlist = res.data.data
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		width: 750rpx;
		height: 100%;
		font-family: PingFang SC;
		background-color: #F7F7F7;

		.main {
			padding-bottom: 80rpx;

			.whole {
				width: 750rpx;
				display: flex;
				flex-direction: column;
				align-items: center;

				.content {
					width: 680rpx;
					display: flex;

					align-items: center;

					image {
						width: 38rpx;
						height: 38rpx;
					}

					.head {
						width: 580rpx;
						padding: 0rpx 10rpx;
						background: #EDF0F2;
						border-radius: 10rpx;
						display: flex;
						align-items: center;

						image {
							width: 38rpx;
							height: 38rpx;
						}

						input {
							display: block;
							width: 531rpx;
							height: 56rpx;
							line-height: 56rpx;
							font-size: 28rpx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #000;
						}
					}

					.content_r {
						padding-left: 30rpx;
						font-size: 32rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #000000;
					}
				}
			}


			.all {
				margin-top: 10rpx;

				.classes {
					padding: 30rpx 30rpx 0rpx 30rpx;
					background-color: #fff;
					margin-bottom: 10rpx;

					.one_of {
						display: flex;
						align-items: center;
						padding-bottom: 26rpx;
						border-bottom: 2rpx solid #F5F7F9;

						.class_l {
							padding-right: 30rpx;

							image {
								width: 230rpx;
								height: 127rpx;
								border-radius: 6rpx;
							}
						}

						.class_r {
							.topic {
								font-size: 27rpx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #353535;
								margin-bottom: 17rpx;
							}

							.name {
								background: #FFFFFF;
								border: 2rpx solid #FF5850;
								border-radius: 6rpx;
								height: 36rpx;
								padding: 4rpx 17rpx;
								font-size: 22rpx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #FF5850;
							}
						}
					}

					.one_bottom {
						display: flex;
						justify-content: space-between;
						align-items: center;
						padding: 20rpx 0;

						.bot_l {
							font-size: 26rpx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #7B7B7B;
						}

						.bot_r {
							font-size: 30rpx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #09B06B;
						}
					}
				}

				.none {
					margin-top: 200rpx;
				}
			}
		}
	}
</style>
